;; The first three lines of this file were inserted by DrRacket. They record metadata
;; about the language level of this file in a form that our tools can easily process.
#reader(lib "htdp-intermediate-lambda-reader.ss" "lang")((modname u4-guebung) (read-case-sensitive #t) (teachpacks ((lib "image.ss" "teachpack" "2htdp"))) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ((lib "image.ss" "teachpack" "2htdp")))))
;; GDI 4. Uebung
(define (multiply x)
 ;; (lambda (y) (* x y)))
  (local
    ((define (xy y)
       (* x y)))
    xy))

;; 4.1
;; contract: f: number number -> number
;; 4.2
;; contract: g: number -> (number -> number)

;; 4.3
(define (add2 x)
  (+ 2 x))
;; 4.4
(define (add3 x)
  (+ 3 x))
(define (add4 x)
  (+ 4 x))

;; 4.5
(define (make-adder x)
  (lambda (y) (+ x y)))

(define (add2v2 x)
  ((make-adder 2) x))

(define (add3v2 x)
  ((make-adder 3) x))

(define (add4v2 x)
  ((make-adder 4) x))

;; 4.6
(define (add x y)
  ((make-adder x) y))

;; 4.7
(define (uncurry f x)
  (lambda (y) (f x)))
    
;; 5.1
    ;; contract: map: (x -> y) (listof x) -> (listof y)
;; 5.2
    (define (my-map f aloa)
      (cond [(empty? aloa) empty]
            [else (cons (f (first aloa)) (my-map f (rest aloa)))]))
;; 5.3
    (foldr - 4 '( 1 2 3 4))
    